package ar.com.solidussource.howmuchservices.common.entities.filter;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import ar.com.solidussource.framework.backend.dao.filter.OrderedFilter;

public class ProductpriceFilter extends OrderedFilter {
	
	private Integer marketId;
	private Integer productId;
	private Integer[] productIds;
	
	public ProductpriceFilter() {
		super();
	}

	public Integer getMarketId() {
		return marketId;
	}

	public void setMarketId(Integer marketId) {
		this.marketId = marketId;
	}

	public Integer getProductId() {
		return productId;
	}

	public void setProductId(Integer productId) {
		this.productId = productId;
	}
		
	public Integer[] getProductIds() {
		return productIds;
	}

	public void setProductIds(Integer[] productIds) {
		this.productIds = productIds;
	}

	@Override
	public void fillCriteriaNotPagination(Criteria arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void fillCriteriaNoOrder(Criteria criteria) {
		if (getMarketId() != null) {
			criteria.add(Restrictions.eq("market.id", this.marketId));
		}
		if (getProductId() != null) {
			criteria.add(Restrictions.eq("product.id", this.productId));
		}
		if(getProductIds() != null && getProductIds().length > 0) {
			criteria.add(Restrictions.in("product.id", this.productIds));
		}		
		criteria.add(Restrictions.eq("deleted", false));		
	}

}
